#include <buola/gui/cwindow.h>
#include <buola/image/cgc.h>
#include <buola/app/ceventloop.h>
#include <buola/widgets/cbutton.h>
#include <buola/widgets/ceditbox.h>

using namespace buola;

class CTestWindow : public gui::CWindow
{
public:
    CTestWindow()
    {
        SetBackColor(img::CColor(0.7,0.7,0.7));
        SetTitle(L"widget test");

        mButton=new gui::CButton;
        mButton->MoveResize(CPoint_d(100,100),CSize_d(100,40));
        Place(mButton);
        mEdit=new gui::CEditBox;
        mEdit->MoveResize(CPoint_d(100,200),CSize_d(150,25));
        Place(mEdit);
    }
    
    void OnMouseIn(const gui::CMouseEvent &pE)
    {
        msg_info() << "onmousein\n";
    }
    
    void OnMouseOut(const gui::CMouseEvent &pE)
    {
        msg_info() << "onmouseout\n";
    }
    
    void OnMouseMove(const gui::CMouseEvent &pE)
    {
        msg_info() << "onmousemove\n";
    }
    
    void OnButtonDown(const gui::CMouseEvent &pE)
    {
        msg_info() << "onbuttondown\n";
        
    }
    
    void OnButtonUp(const gui::CMouseEvent &pE)
    {
        msg_info() << "onbuttonup\n";
    }
    
    void OnMouseWheel(const gui::CMouseEvent &pE)
    {
        msg_info() << "onmousewheel\n";
    }

    gui::PButton mButton;
    gui::PEditBox mEdit;
};

typedef intrusive_ptr<CTestWindow> PTestWindow;

int main(int pNArg,char **pArgs)
{
    buola_init(pNArg,pArgs);

    try
    {
        PTestWindow lWindow=new CTestWindow;
        lWindow->Map();

        get_main_event_loop().Loop();
    }
    catch(std::exception &pE)
    {
        msg_info() << "caught exception " << pE.what() << "\n";
    }

    return buola_finish();
}
